<template>
	<view>
		<view class="box">
			<view class="title red">
				{{item[$t("item.product")]}}
				({{item.num}}{{releaseInfo[$t("item.number_unit")]}})
			</view>
			
			<view class="lineP">
				<Tag :text="(item.price || 0) + $t(item.price_unit) + '/' + releaseInfo[$t('item.number_unit')]"
					color="#2b7deb"></Tag>
			</view>
			
			<view class="lineP">
				<Tag :text="item.product_weight+'kg'" color="#008aff"></Tag>
				<Tag :text="item.product_volume+'m³'" color="#ff7200"></Tag>
			</view>
			
			<view class="lineP">
				<view>{{$t("品牌")}}:</view>
				{{item[$t("item.brand")]}}
			</view>
			
			
			
			<view class="lineP">
				<view>{{$t("货物出发(所在)地")}}:</view>
				<block v-if="lang==='zh'">
					{{item.product_address?item.product_address.mergename:''}}
				</block>
				<block v-if="lang!='zh'">
					{{item.product_address?item.product_address.mergename_ru:''}}
				</block>
			</view>
			
			<view class="lineP">
				<view>{{$t("具体位置")}}:</view>
				{{item[$t("item.product_address_details")]}}
			</view>
			
			<view class="lineP" style="display: inline-block;" v-if="parameter&&parameter.length!=0">
				<view>{{$t("自定义参数规格")}}:</view>
				<view class="lineP" v-for="(it,ind) in parameter" :key="ind" v-if="parameter.length!=0" style="display: flex;border-bottom: 0rpx solid #ccc;margin-bottom: 0rpx;">
					<view class="label" :class="lang!='zh'?'ru_font':''" style="width:100%; font-weight: 500;">
					{{ it.value1 }} : {{ it.value2 }}
					</view>
				</view>
			</view>
			
			
			
			<view class="lineP cloum">
				<view>{{$t("是否缴纳保证金")}}:</view>
				<view>{{item.pay_margin == '0' ? $t("否") : $t("是")}}</view>
			</view>
			<view class="lineP cloum">
				<view>{{$t("保证金金额")}}:</view>
				<view class="price">{{item.margin_amount}}<text class="black">{{$t("元")}}</text></view>
			</view>
			<view class="lineP cloum">
				<view>{{$t("交货时间(天)")}}:</view>
				<view class="">{{item.speed}}<text class="black">{{$t("天")}}</text></view>
			</view>
			<view class="lineP cloum" v-if="item.send_time>0">
				<view>{{$t("发货时间")}}:</view>
				<view class="">{{ time('S', item.send_time,'date')}}</text></view>
			</view>

			<view style="height: 15rpx;width:100%;"></view>
			<block v-if="((item.logo)&&(item.logo!=0)&&(item.logo!='0')&&(item.logo!=null))">
				<u-image width="300rpx" height="300rpx" :border-radius="20"  :src="toImages(item.logo)">
				</u-image>
			</block>
			<block v-else>
				<u-image width="300rpx" height="300rpx" :border-radius="20"  v-if="i==0"
					v-for="(i,j) in storeImages(1, item.buy_images)" :key="j" :src="toImages(i)">
				</u-image>
			</block>
		
		</view>
		<view class="box">
			<ProductWHL :item="item" :type="type"></ProductWHL>
		</view>
	</view>
</template>

<script>
	import {
		IMAGE_URL,
		HTTP_IMG_UTL
	} from '@/config/app'
	import Tag from '@/components/Tag.vue'
	import ProductWHL from '@/components/ProductWHL.vue'
	import {
		ImageUrl,
		isBase64,
		time
	} from "@/common/public";
	export default {
		components: {
			Tag,
			ProductWHL
		},
		props: {
			item: {
				type: Object,
				default: {},
			},
			releaseInfo: {
				type: Object,
				default: {},
			},
			type: {
				type: String | Number,
				default: '1',
			},
		},
		data() {
			return {
				HTTP_IMG_UTL,
				lang: getApp().globalData.lang,
				parameter:[]
			}
		},
		computed: {
			toImages() {
				return (src) => {
					return isBase64(src) ? src : IMAGE_URL + src
				}
			},
		},
		methods: {
			time
		},
		mounted() {
			var that = this
			if(that.item.parameter){
				if (that.lang == 'zh') {
					var parameter = JSON.parse(that.item.parameter.replace(/'/g,'"'))
				} else {
					var parameter = JSON.parse(that.item.parameter_ru.replace(/'/g,'"'))
				}
				that.parameter = parameter
			}
			
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		width: 90%;
		box-shadow: 0 0 10px #ddd;
		border-radius: 10px;
		padding: 10px 12px;
		margin: 0 auto;
		margin-bottom: 20rpx;
		font-size: 30rpx;
		position: relative;
		color: #262626;

		.lineP {
			display: flex;
			margin-top: 30rpx;

			&.cloum {
				flex-direction: column;
				align-items: flex-start;
				margin-top: 20rpx;
			}

			&>view {
				margin-right: 20rpx;
			}

			.price {
				color: #ff1010;
				font-size: 34rpx;

				text {
					margin-left: 8rpx;
					font-size: 24rpx;
				}

				.black {
					color: #262626;
				}
			}
		}

		.title {
			font-weight: 600;
			font-size: 35rpx;
			line-height: 70rpx;

			&.red {
				color: #e33a13;
			}
		}

		.titleContent {
			color: #666666;
			letter-spacing: 4rpx;
			line-height: 45rpx;
		}

		.produceImg {
			position: absolute;
			bottom: 20rpx;
			right: 20rpx;
		}
		.ru_font{ font-size: 20rpx !important;}
		
	}
</style>